<?php
$this->directory = urldecode($this->directory);
if (file_exists($this->directory)) {
    $files = scandir($this->directory);
    natcasesort($files);

    if( count($files) > 2 ) { /* The 2 accounts for . and .. */
        echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";

        foreach( $files as $file ) {
            if( file_exists($this->directory . $file) && $file != '.' && $file != '..' && is_dir($this->directory . $file) ) {
                if (!in_array($this->directory . $file, $this->folderExceptions)) {
                    echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($this->directory . $file) . "/\">" . htmlentities($file) . "</a></li>";
                }
            }
        }
        echo "</ul>";
    }
}
?>